package Poker;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class Deck {
	private final Card[] deck;
	private int indeks;

	public Deck() {
		SecureRandom randomno;
		try {
			randomno = SecureRandom.getInstance("SHA1PRNG");
		} catch (NoSuchAlgorithmException e) {
			randomno = new SecureRandom();
		}
		randomno.nextBytes(new byte[20]); // force SecureRandom to seed itself
		deck = new Card[52];
		int d = 0;

		for (int i = 0; i < 4; i++) {

			for (int j = 0; j < 13; j++) {
				deck[d] = new Card(j, i);
				d++;
			}

		}
		indeks = -1;

		int j;
		Card temp;
		for (int i = 51; i >= 1; i--) {
			j = randomno.nextInt(i + 1);
			temp = deck[j];
			deck[j] = deck[i];
			deck[i] = temp;
		}
	}

	public Card getCard() {
		indeks++;
		return deck[indeks];
	}
}
